
import java.util.concurrent.CountDownLatch;

import com.fourinone.BeanContext;
import com.fourinone.ParkLocal;


public class EasyParkDemo {
   // static ParkLocal pl = BeanContext.getPark();
    public static void main(String[] args){
        long start = System.currentTimeMillis();
        CountDownLatch latch = new CountDownLatch(100);
        for(int i = 0; i < 100;i++){
            Thread t = new Thread(new Worker(i,latch), "t_" + i);
            t.start();
        }
        try {
            latch.await();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println((System.currentTimeMillis() - start) /1000);
    }
    
    private static class Worker implements Runnable {

        private int index;
        private CountDownLatch latch;
        public Worker(int index,CountDownLatch latch){
            this.index = index;
            this.latch = latch;
        }
        @Override
        public void run() {
            
            ParkLocal pl = BeanContext.getPark();
            for(int i = 0; i < 10000;i++){
                
                pl.create("cache", "key-" + index + "-" + i , "value" + i);
            }
            latch.countDown();
        }
        
        
    }
}
